package com.woniu.userservice.entity;

import java.io.Serializable;

public class ResponseResult<T> implements Serializable {
    // json状态码
    private int code;
    // json数据长度
    private int count;
    // json信息
    private String message;
    // json数据
    private T data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public ResponseResult() {

    }

    public ResponseResult(T data) {
        this.code = 200;
        this.count = 10;
        this.message = "";
        this.data = data;
    }

    public ResponseResult(int code, int count, String message) {
        this.code = code;
        this.count = count;
        this.message = message;
    }

    public ResponseResult(int code, int count, String message, T data) {
        this.code = code;
        this.count = count;
        this.message = message;
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResponseResult [code=" + code + ", count=" + count + ", message=" + message + ", data=" + data + "]";
    }

    public static final ResponseResult<Object> SUC = new ResponseResult<>(200, 10, "ok");
    public static final ResponseResult<Object> FORBID = new ResponseResult<>(403, 10, "forbid");
    public static final ResponseResult<Object> NOTFOUND = new ResponseResult<>(404, 10, "not found");
    public static final ResponseResult<Object> ERROR = new ResponseResult<>(500, 10, "error");
}
